package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiLookupIncludeAutomatically;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 员工上班时间统计表
 */
@JsonApiResource(type = "staffworktimestat")
@Table(name = "tnb_staff_worktime_stat")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class StaffWorkTimeStat extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private String remark;// 备注

	private Employee employee;// 护工
	
	private Integer statime;

	private Integer startWorkTime;// 当天到岗最早时间

	private Room startWorkPoint;// 地点

	private Integer endWorkTime;// 当天离岗最晚时间

	private Room endWorkPoint;// 签到地点

	@Column(name = "stat_time")
	public Integer getStatime() {
		return statime;
	}

	public void setStatime(Integer statime) {
		this.statime = statime;
	}

	@Column(name = "startwork_time")
	public Integer getStartWorkTime() {
		return startWorkTime;
	}

	public void setStartWorkTime(Integer startWorkTime) {
		this.startWorkTime = startWorkTime;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "start_room_id", foreignKey = @ForeignKey(name = "null"))
	public Room getStartWorkPoint() {
		return startWorkPoint;
	}

	public void setStartWorkPoint(Room startWorkPoint) {
		this.startWorkPoint = startWorkPoint;
	}

	@Column(name = "endwork_time")
	public Integer getEndWorkTime() {
		return endWorkTime;
	}

	public void setEndWorkTime(Integer endWorkTime) {
		this.endWorkTime = endWorkTime;
	}

	@JsonApiToOne
	@JsonApiLookupIncludeAutomatically
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "end_room_id", foreignKey = @ForeignKey(name = "null"))
	public Room getEndWorkPoint() {
		return endWorkPoint;
	}

	public void setEndWorkPoint(Room endWorkPoint) {
		this.endWorkPoint = endWorkPoint;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	// @Fetch(FetchMode.JOIN)
	// @JoinColumn(name = "worktimesetting_id", foreignKey = @ForeignKey(name =
	// "null"))
	// public WorkTimeSetting getWorkTimeSetting() {
	// return workTimeSetting;
	// }
	//
	// public void setWorkTimeSetting(WorkTimeSetting workTimeSetting) {
	// this.workTimeSetting = workTimeSetting;
	// }

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "employee_id", foreignKey = @ForeignKey(name = "null"))
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public StaffWorkTimeStat() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
